//
//  AddImageHeader.m
//  VideoData
//
//  Created by pro1 on 2019/3/7.
//  Copyright © 2019 pro1. All rights reserved.
//

#import "AddImageHeader.h"

#import <SPPageMenu/SPPageMenu.h>

@interface AddImageHeader ()<SPPageMenuDelegate>

@property (strong,nonatomic) SPPageMenu *menu;

@end

@implementation AddImageHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.menu];
        [self.menu setItems:@[@"风景",@"食物",@"摄影",@"城市",@"人文"] selectedItemIndex:0];
        
//        [self get]
    }
    return self;
}

-(SPPageMenu *)menu{
    if (!_menu) {
        _menu  = [[SPPageMenu alloc] initWithFrame:self.bounds trackerStyle:SPPageMenuTrackerStyleLineAttachment];
       _menu.selectedItemTitleColor = UIColorMakeWithHex(@"#F5A623");
       _menu.unSelectedItemTitleColor = UIColorMakeWithHex(@"#606060");
       _menu.tracker.backgroundColor = UIColorMakeWithHex(@"#F5A623");
       _menu.itemTitleFont = [UIFont systemFontOfSize:14];
       _menu.dividingLine.hidden = YES;
        _menu.delegate = self;
        _menu.permutationWay = SPPageMenuPermutationWayNotScrollEqualWidths;
    }
    return _menu;
}

- (void)pageMenu:(SPPageMenu *)pageMenu itemSelectedFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex{
    if (fromIndex == toIndex) {
        return;
    }
    if (self.sectionHeaderBlock) {
        self.sectionHeaderBlock(toIndex);
    }
}

@end
